package educar.gui;

import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.LayoutManager;

import javax.swing.BorderFactory;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
import javax.swing.UIManager;
import javax.swing.WindowConstants;
import javax.swing.border.EmptyBorder;

//import com.jgoodies.forms.factories.CC;
import educar.controllers.DatosController;
import educar.controllers.IController;
import educar.controllers.LoginController;
import educar.models.Session;

public class DatosView extends JPanel implements IView {
	private JFrame jfWindow;
	JLabel label1;
	JTextField textField1;
	 JLabel label2;
	JLabel label3;
 JTextField textField2;
	 JLabel label4;
	 JTextField textField3;
	JLabel label5;
	JTextField textField4;
	JLabel label6;
	 JTextField textField5;
	 JLabel label7;
	JTextField textField6;
	 JLabel label8;
	 JTextField textField7;
	 JButton button1;

	public DatosView() {
		jfWindow = new JFrame();
		Container container = jfWindow.getContentPane();

		setupMainContainer(container);

		jfWindow.pack();
		jfWindow.setVisible(true);
		jfWindow.setResizable(false);
		jfWindow.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
	}

	private void setupMainContainer(Container container) {
		container.setLayout((LayoutManager) new BoxLayout(jfWindow
				.getContentPane(), BoxLayout.Y_AXIS));

		((JComponent) container).setBorder(new EmptyBorder(0, 50,50, 50));

		JLabel lblWelcome = new JLabel(" CARGAR DATOS");
		lblWelcome.setAlignmentX(Component.CENTER_ALIGNMENT);
		lblWelcome.setFont(new Font("Serif", Font.BOLD, 16));
		lblWelcome.setBorder(new EmptyBorder(0, 10, 10, 10));
		container.add(lblWelcome);

		// Lay out the buttons from left to right.
		JLabel label1 = new JLabel("NOMBRE :");    
		textField1 = new JTextField(20);
		JPanel usernamePane = new JPanel();
		usernamePane.setLayout(new BoxLayout(usernamePane, BoxLayout.LINE_AXIS));
		usernamePane.setBorder(BorderFactory.createEmptyBorder(0, 10, 10, 10));
		usernamePane.add(Box.createHorizontalGlue());
		usernamePane.add(label1);
		
		usernamePane.add(Box.createRigidArea(new Dimension(10, 0)));
		usernamePane.add(label1);
		usernamePane.add(textField1);
		container.add(usernamePane);

		//------------------------------------------------------
	   JLabel label2 = new JLabel ("APELLIDO:"); 
		textField2 = new JTextField(20);
		JPanel usernamePane2 = new JPanel();
		usernamePane2.setLayout(new BoxLayout(usernamePane2, BoxLayout.LINE_AXIS));
		usernamePane2.setBorder(BorderFactory.createEmptyBorder(0, 10, 10, 10));
		//usernamePane2.add(Box.createHorizontalGlue());
		usernamePane2.add(label2);	
		usernamePane2.add(Box.createRigidArea(new Dimension(10, 0)));
		usernamePane2.add(textField2);	
		container.add(usernamePane2);
		
		//--------------------------------------------------------------
		textField3 = new JTextField(20);
	    JLabel label3 = new JLabel ("DNI:"); 
		JPanel usernamePane3 = new JPanel();
		usernamePane3.setLayout(new BoxLayout(usernamePane3, BoxLayout.LINE_AXIS));
		usernamePane3.setBorder(BorderFactory.createEmptyBorder(0, 10, 10, 10));
		usernamePane3.add(Box.createHorizontalGlue());
		usernamePane3.add(label3);	
		usernamePane3.add(Box.createRigidArea(new Dimension(55,0)));
		usernamePane3.add(textField3);	
		container.add(usernamePane3);

		//-------------------------------------------------------------------
		textField4 = new JTextField(20);
		   JLabel label4 = new JLabel ("DIRECCION:"); 
			JPanel usernamePane4 = new JPanel();
			usernamePane4.setLayout(new BoxLayout(usernamePane4, BoxLayout.LINE_AXIS));
			usernamePane4.setBorder(BorderFactory.createEmptyBorder(0, 10, 10, 10));
			usernamePane4.add(label4);	
			usernamePane4.add(Box.createRigidArea(new Dimension(0,10)));
			usernamePane4.add(textField4);	
			container.add(usernamePane4);
			
			//------------------------------------------------------
			
			textField5 = new JTextField(20);
			   JLabel label5 = new JLabel ("TELEFONO:"); 
				JPanel usernamePane5 = new JPanel();
				usernamePane5.setLayout(new BoxLayout(usernamePane5, BoxLayout.LINE_AXIS));
				usernamePane5.setBorder(BorderFactory.createEmptyBorder(0, 10, 10, 10));
				usernamePane5.add(label5);	
			    usernamePane5.add(Box.createRigidArea(new Dimension(0,10)));
				usernamePane5.add(textField5);	
				container.add(usernamePane5);
		
			//-----------------------------------------------------------------	
				textField6 = new JTextField(20);
				   JLabel label6 = new JLabel ("MAIL:"); 
					JPanel usernamePane6 = new JPanel();
					usernamePane6.setLayout(new BoxLayout(usernamePane6, BoxLayout.LINE_AXIS));
				usernamePane6.setBorder(BorderFactory.createEmptyBorder(0, 10, 10, 10));
					usernamePane6.add(label6);	
				usernamePane6.add(Box.createRigidArea(new Dimension(45,0)));
					usernamePane6.add(textField6);	
					container.add(usernamePane6);
				

				   
			  
		
		//---- button1 ----
				
		JButton baceptar = new JButton("ACEPTAR");
	baceptar.setAlignmentX(Component.RIGHT_ALIGNMENT);
		container.add(baceptar);
		
		LoginListener buttonListener = new LoginListener();
	IController loginController = new DatosController();
	loginController.setView(this);
	buttonListener.associate(baceptar, loginController);

	}
	
	
	 public String getNombre() {
         return textField1.getText().trim();
 }
	 
	 public String getApellido() {
         return textField2.getText().trim();
 }
	 public String getDni() {
         return textField3.getText().trim();
 } 
	 public String getDireccion() {
         return textField4.getText().trim();
 } 
	 public String getTelefono() {
         return textField5.getText().trim();
 } 
	 public String getMail() {
         return textField6.getText().trim();
 } 
	  
	 
	 
	 public void present(String model) {
			JOptionPane.showMessageDialog(null, model);
		}


	
	public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
				try {
					UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
				} catch (Exception ex) {
					// ignore
				}
               javax.swing.JFrame frame = new javax.swing.JFrame("Datos");
                frame.setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
                frame.getContentPane().add(new DatosView());
                frame.pack();
                frame.setVisible(false);
             
            }
        });
    }
}